var TAB_DATA_GRAPH={noOfGraphs:0};
$(document).ready(function() {
	 $("#tabs").tabs();
	 hideResults(); 
	 $('form').submit(function() {
		 $(".error").hide();
		 if($("#fromDt").val() != "" && $("#toDt").val() != ""){
	 		 TAB_DATA_GRAPH.noOfGraphs= TAB_DATA_GRAPH.noOfGraphs+1;		 		 
			  	if( TAB_DATA_GRAPH.noOfGraphs>4){
				  //reset to first tab
			  		TAB_DATA_GRAPH.noOfGraphs=1;
				}	 	
			  	$("#graph-iframe-"+TAB_DATA_GRAPH.noOfGraphs).attr('src',contextRoot+'/factorAnalysis/graphdummy.html'+'?'+$(this).serialize());
			  	$("#tabs").tabs('select', TAB_DATA_GRAPH.noOfGraphs);
		 		$("#tab-graph-"+TAB_DATA_GRAPH.noOfGraphs).css("display","list-item");	 	
		 		return false;
	 	}
		else{
			$("#validation")
			.after(
					'<span class="error" style="color: red">Please choose atleast one value in all fields.</span>');
			return false;	 		
	 	}
	 });	 
});

function hideResults(){
	 $("#tab-graph-1").css("display","none");
	 $("#tab-graph-2").css("display","none");
	 $("#tab-graph-3").css("display","none");
	 $("#tab-graph-4").css("display","none");	 
}

function PrintContent()
{
	var DocumentContainer = document.getElementById('printDiv');
	var WindowObject = window.open("", "PrintWindow",
	"width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
	WindowObject.document.writeln(DocumentContainer.innerHTML);
	WindowObject.document.close();
	WindowObject.focus();
	WindowObject.print();
	WindowObject.close();
}